<#assign tit>上传证件</#assign>
<@page.html title=tit>
<script type="text/javascript" src="${_appPath!}/js/upload.js"></script>
<script type="text/javascript">
  function doUpload(fm) {
    if(_isupl) return;
    if(!chkfile(fm.file.value)) return false;
    _isupl = true;
    return true;
  }
  function chkfile(ff) {
    if(ff!="") {
      var ext = ff.substr(ff.length-4).toLowerCase();
      if(ext==".gif" || ext==".jpg" || ext==".png" || ext==".flv") {
        return true;
      } else
        window.alert("只能上传gif,jpg,png和flv格式");
    } else {
      window.alert("请选择文件");
    }
    return false;
  }
  function uploadSucc(f) {
    window.alert("上传成功");
    _fupl = f;
    var td = getEl("td_img");
    if(td) td.innerHTML = '<img src="${_picPath!}'+ f.furl+'" style="max-width:400px;"/>';
  }

  var _fupl = null;
  function doOk() {
    if(!_fupl) {
      window.alert("请上传照片");
      return;
    }
    if(window.parent && window.parent.uploadOk2)
      window.parent.uploadOk2(_fupl);
    cancel();
  }
  function cancel() {
    if(window.parent && window.parent.closeWin)
      window.parent.closeWin();
    else
      window.close();
  }
</script>
<div>

  <form id="fm_upload" method="post" action="_upload" enctype="multipart/form-data" target="ifm_upload" onsubmit="return doUpload(this);">
    <div class="kbox">
      <table class="input">
        <tr>
          <td colspan="2" id="td_img"></td>
        </tr>
        <tr>
          <th>选择图片</th>
          <td><input type="file" name="file"></td>
        </tr>
      </table>
      <div class="button" style="margin:10px;"><input type="submit" value="上传">  <input type="button" value="确定" onclick="doOk();"></div>
    </div>
  </form>
  <iframe name="ifm_upload" onload="uploadOk(this);" style="width:0px; height:0px; display:none;"></iframe>
</div>
</@page.html>